/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package utilities;

import java.security.InvalidParameterException;
import javax.servlet.http.HttpServletRequest;


public class ParametersValidator
{
    static public void ValidateProgrammerParameters(HttpServletRequest request, String ... requiredParameters)
    {
        String value = null;
        for (String requiredParameter : requiredParameters)
        {
            value = request.getParameter(requiredParameter);
            if (value == null || value.length() == 0)
            {
                throw new InvalidParameterException();
            }
        }
    }

    static public boolean ValidateUserParameters(HttpServletRequest request, String ... requiredParameters)
    {
        try
        {
            ValidateProgrammerParameters(request, requiredParameters);
            return true;
        }
        catch(InvalidParameterException e)
        {
            return false;
        }
    }
}
